$(function(){
    var obj = {
        userTel: '',
        ajaxStatus: false,
        searchType: '企业',
        init: function () {
            var that = this;
            that.userTel = localStorage.getItem('myTel') || '';
            that.addEvent();
            that.ajaxGetApplyInfoList();
        },
        addEvent: function () {
            var that = this;
            // 切换搜索类型
            $('#searchType').click(function () {
                that.searchType = that.searchType ==='企业'? '岗位':'企业';
                $(this).html(that.searchType);
                $('#searchIpt').val('');
            });
            //搜索
            $('#search').click(function () {
                that.ajaxGetApplyInfoList();
            })
        },
        ajaxGetApplyInfoList: function(){
            var that = this;
            if(that.ajaxStatus) return;
            that.ajaxStatus = true;
            var search = $('#searchIpt').val();
            $.getData({
                url: $.getAjaxHost('def') + 'cxjy/zpinfo/getApplyInfoList',
                type: 'post',
                contentType: 'application/json',
                data: {
                    qy: that.searchType ==='企业'? search:'',
                    gw: that.searchType ==='企业'? '':search
                },
                success: function (res) {
                    that.ajaxStatus = false;
                    if(res.obj.length>0){
                        that.fillLogList(res.obj);
                    }else {
                        $('.logListBox').addClass('none');
                        $('.noData').removeClass('none');
                    }
                },
                error: function (res) {
                    that.ajaxStatus = false;
                }
            })
        },
        fillLogList: function (list) {
            var that = this;
            var data = {};
            data.list = list;
            var html = template('list', data);
            $('#logList').html(html);
            $('.topTip').slideDown();
            setTimeout(function () {
                $('.topTip').slideUp();
            }, 4000);
        }
    };
    obj.init();
});